package com.lg.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 *@Author liujun
 *@2009-11-23上午10:13:13
 *@public class BaseController{ }
 */
public abstract class BaseController  {
	/**
	 * @Title: convert2JSONString
	 * @Description: TODO(把对象转换成json形式)
	 * @param @param object
	 * @return String    
	 * @throws
	 */
	protected String convert2JSONString(Object object)   
	{   
	    JSONArray jsonObject = JSONArray.fromObject(object);   
	    return jsonObject.toString();   
	}  
	protected String convertObject2Json(Object object)   
	{   
		JSONObject jsonObject = JSONObject.fromObject(object);
	    return jsonObject.toString();   
	}  
	/**
	 * @Title: ajaxOutput
	 * @Description: TODO(把结果返回个客户端)
	 * @param @param response
	 *@param outputString  
	 * @return void    返回类型
	 * @throws
	 */
	protected void ajaxOutput(HttpServletResponse response, String outputString)   
	{   
	    response.setContentType("text/html; charset=UTF-8");   
	    try {
			response.getWriter().write(outputString);
			response.getWriter().flush();   
		} catch (IOException e) {
			e.printStackTrace();
		}   
	    
	}  
}
